package vip.liux.backend.adapter.web;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vip.liux.application.dots.PagedResultDto;
import vip.liux.backend.application.service.point.PointsTransactionDto;
import vip.liux.backend.application.service.point.PointsTransactionQueryDto;
import vip.liux.backend.application.service.point.PointsTransactionService;

@RestController
@RequestMapping("/api/points-transaction")
public class PointsTransactionController {


    private final PointsTransactionService pointsTransactionService;

    public PointsTransactionController(PointsTransactionService pointsTransactionService) {
        this.pointsTransactionService = pointsTransactionService;
    }

    /**
     * 分页查询积分交易流水
     *
     * @param userId 用户ID (可选，如果不提供则查询所有用户的交易记录)
     * @param input  查询条件
     * @return 分页结果，包含积分交易记录
     */
    @GetMapping({"/{userId}", ""})
    public PagedResultDto<PointsTransactionDto> pageList(@PathVariable(required = false) Long userId, PointsTransactionQueryDto input) {
        return pointsTransactionService.queryAccount(userId, input);
    }
}
